<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>等待支付</title>

    <script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript">

        function pay() {
            var orderId = getUrlParam('orderId');
            $.ajax({
                url: 'payOrder',
                type: 'POST',    //GET
                async: false,    //或false,是否异步
                data: {"orderId": orderId},
                timeout: 5000,    //超时时间
                dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                success: function (data) {
                    if ("1" === data.code) {
                        window.location.href = "paySucess.html";
                    } else {
                        window.location.href = "cancelOrder.html";
                    }
                }
            })
        }

        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]);
            return null; //返回参数值
        }
    </script>
</head>
<body>


<form>
    <table class="lp-login">
        <tr align="center">
            <td colspan="2">
                <span>等待支付.....</span>
                <button class="submitBtn" onclick="pay();return false;" value="请点击支付...">请点击支付</button>
            </td>
        </tr>
    </table>
</form>

</body>
</html>
